Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prototype: create an entity class out of an excel sheet #40

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

ivy-rew
Copy link
Member

@ivy-rew ivy-rew commented Oct 5, 2023

No description provided.

Comment on lines 42 to 45
String fqName = manager.getDefaultNamespace()+"."+dataName;
if (manager.findDataClass(fqName) != null) {
throw new RuntimeException("entity "+fqName+" already exists");
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you may choose more appropriately how to treat existing classes ... overwrite? delete and forget? ask the user?

Comment on lines 106 to 119
switch (cell.getCellType()) {
case NUMERIC:
entity.addField(name, Float.class.getName());
break;
case STRING:
entity.addField(name, String.class.getName());
break;
case BOOLEAN:
entity.addField(name, Boolean.class.getName());
break;
default:
entity.addField(name, String.class.getName());
break;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handle more types?

var name = StringUtils.uncapitalize(names.get(cellNo));
switch (cell.getCellType()) {
case NUMERIC:
entity.addField(name, Float.class.getName());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe on the created field we should also apply some magic: e.g define the max length of the string field or whatever

Comment on lines 22 to 31
void readToEntity(@TempDir Path dir) throws IOException {
Path path = dir.resolve("customers.xlsx");
try(InputStream is = TestEntityClassCreator.class.getResourceAsStream("sample.xlsx")) {
Files.copy(is, path, StandardCopyOption.REPLACE_EXISTING);
}

var reader = new EntityClassReader();
var entity = reader.getEntity(path.toFile().toString());
assertThat(entity).isNotNull();
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run me to create the 'customers' entity out of the given static sample.xlsx
entityClassCreator

@ivy-rew ivy-rew marked this pull request as ready for review October 19, 2023 09:39
@github-actions
Copy link
Contributor

github-actions bot commented Oct 19, 2023

Test Results

0 tests   0 ✔️  0s ⏱️
0 suites  0 💤
0 files    0

Results for commit d9937aa.

♻️ This comment has been updated with latest results.

@ivy-rew ivy-rew force-pushed the entityCreator branch 2 times, most recently from 94606cf to 80a8d0d Compare October 19, 2023 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant